<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%
	StringBuffer strURL = request.getRequestURL();
	String URL = strURL.toString();
	String contPath = request.getContextPath();
	int nIndex = URL.indexOf(contPath);
	URL = "http://tugo.cn/weixin_aef/";
	%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
	content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="<%=URL%>newedition/css/aui.css" />
<link rel="stylesheet" href="<%=URL%>newedition/css/iconfont.css" />
<link rel="stylesheet" href="<%=URL%>newedition/css/aui-slide.css" />
<link rel="stylesheet"
	href="<%=URL%>newedition/css/user_functionAddressList.css" />
<link rel="stylesheet"
	href="<%=URL%>newedition/css/aui-pull-refresh.css" />
<script type="text/javascript"
	src="<%=URL%>newedition/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript"
	src="<%=URL%>newedition/js/aui-slide.js"></script>
<script type="text/javascript" src="<%=URL%>js/base64.js"></script>
<script type="text/javascript"
	src="<%=URL%>newedition/js/aui-toast.js"></script>
<script type="text/javascript"
	src="<%=URL%>newedition/js/auipopupstyle.js"></script>
<script type="text/javascript"
	src="<%=URL%>newedition/js/base.js?version=3.4"></script>
<script type="text/javascript"
	src="<%=URL%>js/cookies.js?version=1.1"></script>
<script type="text/javascript"
	src="<%=URL%>newedition/js/aui-pull-refresh.js"></script>
<script type="text/javascript"
	src="<%=URL%>newedition/js/doRefresh.js"></script>
<script type="text/javascript"
	src="<%=URL%>newedition/js/aui-dialog.js"></script>
<script type="text/javascript"
	src="<%=URL%>newedition/js/recycle/user_functionAddresslist.js"></script>
<script type="text/javascript" src="<%=URL%>js/doT.min.js"></script>
<title>发起售油</title>
</head>

<body>
	<header class="aui-bar aui-bar-nav "><!--  <a
		class="aui-pull-left aui-btn"> <span
		class="aui-iconfont aui-icon-left"></span> -->
	</a>
	<div class="aui-title">收货地址</div>
	<a class="aui-pull-right aui-btn "> <span class="aui-iconfont ">管理</span>
	</a> </header>
	<div class="aui-refresh-content">
		<div id="dotmainhtml"></div>
		<script type="template" id="dotTmpl">
		{{if(it.rows.length!=0){ }}
  		 {{ for(var i=0;i<it.rows.length;i++){	}}	
			<div class="aui-content aui-margin-b-15">
				<ul class="aui-list aui-media-list" onclick="onclickaddressli('{{=it.rows[i].id}}','{{=it.rows[i].address}}','{{=it.rows[i].mobile}}')">
					<li class="aui-list-item aui-list-item-middle">
						<div class="aui-media-list-item-inner">
							<div class="aui-list-item-inner">
								<div class="aui-list-item-text">
									<div class="aui-list-item-title aui-font-size-14">
										<span class="realname"></span>
									</div>
									<div class="aui-list-item-right">
						{{if(it.rows[i].mobile=="null"){ }}
						
						{{}}}
						{{else{}}
						{{=it.rows[i].mobile}}
						{{}}}
						</div>
								</div>
								<div class="aui-list-item-text">
									<!--<span style="color: #ff4200;width: 50%;">[默认地址]</span>-->
									<span>地址:{{=it.rows[i].address}}</span>
								</div>
							</div>
						</div>
					</li>
				</ul>
				<div class="addressChange aui-padded-10">
					<div class="addressChange-left">
						{{if(it.addressid==it.rows[i].id){ }}
						<input class="aui-checkbox" type="radio" name="checkbox" checked >
						{{}}}
						{{else{}}
						<input class="aui-checkbox" type="radio" name="checkbox"  >
						{{}}}
						<span>设为默认</span>
					</div>
					<div class="addressChange-right">
						<span onclick="$(location).attr('href', 'user_functionEditAddress.jsp?addressid={{=it.rows[i].id}}');"><i class="aui-iconfont aui-icon-edit"></i>编辑</span>
						<span onclick="deleteAddress({{=it.rows[i].id}})"><i class="aui-iconfont aui-icon-trash"></i>删除</span>
					</div>
				</div>
			</div>
	  {{ } 	}}
{{}}}
       </script>
	</div>
	<footer
		onclick="$(location).attr('href', 'user_functionAddAddress.jsp');">添加新地址</footer>
</body>

<script>
	$(function() {
		getHistoryAddress()
	})
		var dialog = new auiDialog();
		var toast = new auiToast();
		function deleteAddress(id) {
			dialog.alert({
				title: "是否删除该地址？",
				//	msg: '这里是内容',
				buttons: ['取消', '确定']
			}, function(ret) {
				if(ret.buttonIndex == 2) {
					showDefault("loading","删除中...");
					delHistoryAddress(id)
					/* toast.success({
						title: "删除成功",
						duration: 2000
					}); */
				}
				console.log(ret)
			})
		}
		dorefresh();
		
		function getHistoryAddress(){
			showDefault("loading","加载中...");
			var jsonstr = "filterscount=0&groupscount=0&pagenum=0&pagesize=10&recordstartindex=0&recordendindex=10&iphone="+getCookie("useriphone")+"&addressLike=";
			$.ajax({
				cache: false,
				type: "post",
				datatype: 'json',
				contentType: 'application/json;charset=UTF-8',
				data: jsonstr,
				url: ''+httpipstr+'alfa-mobile-ws/rest/historyaddress/findlist?mobiletoken='+getCookie("mobiletokenuser")+'',
				success: function(data) {
					toast.hide();
					var tmpl = doT.template($("#dotTmpl").html());
					data.addressid=getCookie("recycleaddressid");
					// 将数据扔进templ中。并在DIV中显示出来
					$("#dotmainhtml").html(tmpl(data));
					$(".realname").html("售油人："+""+getCookie("realname")+"")
				}
			})
		}
	</script>

</html>